package com.zoroki.hmusic.es;

import co.elastic.clients.json.JsonpDeserializer;
import com.zoroki.hmusic.entity.Song;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.elasticsearch.annotations.Highlight;
import org.springframework.data.elasticsearch.annotations.HighlightField;
import org.springframework.data.elasticsearch.core.SearchHits;
import org.springframework.data.elasticsearch.repository.ElasticsearchRepository;
import org.springframework.stereotype.Repository;

@Configuration
public interface EsSongRepository extends ElasticsearchRepository<Song,String> {
    @Highlight(fields = {
            @HighlightField(name = "name"),
            @HighlightField(name = "singer"),
            @HighlightField(name = "lyricist"),
            @HighlightField(name = "composer"),
            @HighlightField(name = "remark"),
    })
    SearchHits<Song> findSongByNameOrSingerOrLyricistOrComposerOrRemark(
            String name,
            String singer,
            String lyricist,
            String composer,
            String remark
    );


    @Highlight(fields = {
            @HighlightField(name = "name"),
            @HighlightField(name = "singer"),
            @HighlightField(name = "lyricist"),
            @HighlightField(name = "composer"),
            @HighlightField(name = "remark"),
    })
    Page<Song> findSongsByNameOrSingerOrLyricistOrComposerOrRemark(
            String name,
            String singer,
            String lyricist,
            String composer,
            String remark,
            Pageable pageable
    );

}
